﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using StudySystem.MainLogic.Items;
using StudySystem.MainLogic.FormControl;

namespace StudySystem.Windows
{
    enum AnswerState
    {
        Show,
        Hide
    };
    public partial class Question : UserControl
    {
        private ClassQuestion ques;
        AnswerState answerState = AnswerState.Show;

        public ClassQuestion Ques { get => ques; set => ques = value; }

        public Question()
        {
            InitializeComponent();
        }
        public Question(ClassQuestion question)
        {
            InitializeComponent();
            this.Ques = question;
        }
        private void richTextBox1_TextChanged(object sender, EventArgs e)
        {
            
        }

        private void richTxtAnswer_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            //改变当前状态  与当前状态相反
            answerState = (AnswerState)((int)(answerState + 1) % 2);
            //根据当前状态调整显示状况
            FormController.TxtShowControl(answerState, richTxtAnswer,Ques.Answer);

        }


        private void Question_Load(object sender, EventArgs e)
        {
            richTxtQuestion.Text = Ques.QuestionContent;
            richTxtAnswer.Text = Ques.Answer;
            rbtnRight.Tag = AnswerResult.RIGHT;
            rbtnVague.Tag = AnswerResult.VAGUE;
            rbtnWrong.Tag = AnswerResult.WRONG;
            lblQuesRecode.Text = Ques.ShowRecord();
            lblAccurarcy.Text = "正确率：" + Ques.Accuracy;
        }

        private void btnDelete_Click(object sender, EventArgs e)
        {
            Ques.DeleteQuestion();
            FormQuesControl.DeleteAQuestion((FlowLayoutPanel)Parent, this);
        }

        private void btnRevise_Click(object sender, EventArgs e)
        {
            FormModifyQues modifyQues = new FormModifyQues(Ques,this);
            modifyQues.Show();
        }

    }
}
